package com.pt.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@ApiModel(description = "接口统一返回对象")
public class ApiResponse<T> {
    @ApiModelProperty(value = "状态码", example = "200")
    private Integer code;
    
    @ApiModelProperty(value = "返回信息", example = "success")
    private String message;
    
    @ApiModelProperty(value = "返回数据")
    private T data;

    public static <T> ApiResponse<T> success(T data) {
        return new ApiResponse<T>()
                .setCode(200)
                .setMessage("success")
                .setData(data);
    }

    public static <T> ApiResponse<T> error(String message) {
        return new ApiResponse<T>()
                .setCode(500)
                .setMessage(message);
    }

    public static <T> ApiResponse<T> error(Integer code, String message) {
        return new ApiResponse<T>()
                .setCode(code)
                .setMessage(message);
    }
} 